var basePath = "/";
var warCategoryHandle = new ListHandle({
  basePath: basePath,
  tableId: '#grid-table',
  pagerId: '#grid-pager',
  formId: '#queryForm',
  entityName: '作战图分类',
  winWidth: '80%',
  winHeight: '400px',
  primaryKey: 'cateId',
  urls:{
    list: basePath+'warCategory/list',
    addBefore: basePath+'common/mgr/warCategory/addWarCategory',
    editBefore: basePath+'warCategory/editBefore',
    enabled: basePath+'warCategory/enabled',
    disabled: basePath+'warCategory/disabled',
    deleted: basePath+'warCategory/deleted',
  }
},{});
$(function(){
  var colNames = ['分类id', '分类名称', '分类图标', '父级分类', '创建日期', '创建人', '更新日期', '更新人', '操作'];
  var colModel = [
    {name: 'cateId', index: 'cate_id', width: 50, align: "center", formatter: function(cellvalue, options, rowObject){
      return cellvalue.toFixed(0);
    }}, 
    {name: 'name', index: 'name', width: 50, align: "center"}, 
    {name: 'icon', index: 'icon', width: 50, align: "center"}, 
    {name: 'parentId', index: 'parent_id', width: 50, align: "center"}, 
    {name: 'createTime', index: 'create_time', width: 50, align: "center", formatter:'date', formatoptions: {newformat:'Y-m-d H:i:s'}}, 
    {name: 'createUser', index: 'create_user', width: 50, align: "center"}, 
    {name: 'updateTime', index: 'update_time', width: 50, align: "center", formatter:'date', formatoptions: {newformat:'Y-m-d H:i:s'}}, 
    {name: 'updateUser', index: 'update_user', width: 50, align: "center"}, 
    {align: "center", editable: false, sortable: false, formatter: function(cellvalue, options, rowObject){
      var temp = '';
      if(hasAuthorize('warCategory-editBefore')){
        temp += '<a class="linetaga" href="javascript: warCategoryHandle.edit(\'' + rowObject.cateId.toFixed(0) + '\');" >编辑</a>';
      }
      if(rowObject.enabled==1){
        if(hasAuthorize('warCategory-disabled')){
          temp += '<a class="linetaga" href="javascript: warCategoryHandle.disabled(\'' + rowObject.cateId.toFixed(0) + '\');" >禁用</a>';
        }
      }else{
        if(hasAuthorize('warCategory-enabled')){
          temp += '<a class="linetaga" href="javascript: warCategoryHandle.enabled(\'' + rowObject.cateId.toFixed(0) + '\');" >启用</a>';
        }
      }
      return temp;
    }}
  ];
  var rowList = [10, 20, 30, 50];
  var rownumbers = true;
  var multiselect = true;
  var config={caption: "作战图分类列表", colNames: colNames, colModel: colModel, rowList: rowList, rownumbers: rownumbers, multiselect: multiselect};
  warCategoryHandle.init(config);
});